package org.beetl.json.loc;

import org.beetl.json.Location;
import org.beetl.json.OutputNode;
import org.beetl.json.PolicyParser;

public class PathAttributeLocation extends Location {
	String attr;
	String policy;
	String subLocation;
	String action = null;
	public PathAttributeLocation(String atrr,String subLocation,String action){
		this.attr = atrr;
		this.subLocation = subLocation;
		this.action = action ;
		this.policy = subLocation+":"+action;
		
	}
	@Override
	public boolean match(OutputNode node,Class type, String field) {
		if(field.equals(attr)){
			if(subLocation.startsWith("[")){
				//应该传递给集合项，而不是集合本身
				IndexLocation l = (IndexLocation)PolicyParser.parse(type, subLocation, action,tool);
				node.addIndexLocations(l);
				
			}else{
				node.addInheritedPolicy(policy);
			}
			
		}
		return false;
	}
	

	
	

}
